package kz.simplex.photobox.action;

import kz.simplex.photobox.model.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("photoList")
public class PhotoList extends EntityQuery<Photo> {

	private static final String EJBQL = "select photo from Photo photo";

	private static final String[] RESTRICTIONS = {
			"lower(photo.cameraBrand) like lower(concat(#{photoList.photo.cameraBrand},'%'))",
			"lower(photo.cameraModel) like lower(concat(#{photoList.photo.cameraModel},'%'))",
			"lower(photo.dsc) like lower(concat(#{photoList.photo.dsc},'%'))",
			"lower(photo.link) like lower(concat(#{photoList.photo.link},'%'))",
			"lower(photo.title) like lower(concat(#{photoList.photo.title},'%'))",
			"lower(photo.type) like lower(concat(#{photoList.photo.type},'%'))",};

	private Photo photo = new Photo();

	public PhotoList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Photo getPhoto() {
		return photo;
	}
}
